define("src/views/product/index/index",
    function(e) {
        {
            var t = e("node_modules/jquery/dist/jquery"),
                n = (e("node_modules/underscore/underscore"), e("node_modules/fastclick/lib/fastclick"));
            e("node_modules/slick-carousel/slick/slick")
        }
        t(function() {
            function e() {
                n(document.body),
                    m(),
                    R(),
                    K(),
                1 == Q && r(),
                    rt.on("scroll", x(E())).on("load",
                        function() {
                            ut = X.offset().top
                        }),
                    t(".go-to-form").on("click",
                        function(e) {
                            e.preventDefault(),
                                t("body").animate({
                                    scrollTop: X.offset().top - 60
                                }),
                                t(this).hasClass("btn-online-buy") ? F() : A()
                        }),
                    t(".btn-tel-buy").click(function() {
                        G()
                    }),
                    t("#main").on("click", "a:not([href^=tel])",
                        function(e) {
                            e.preventDefault()
                        }),
                window.TM.ENV.isInToutiao && i(!1),
                $() && (Y(!1), Ot && t('<div class="header-notice"><img src="https://p3a.pstatp.com/large/26fb0006d65e64045c56" />您的红包可在下单抵扣<span class="money-amount">' + at.red_pocket_number + '</span>元现金<span class="close">&#215;</span></div>').on("click", ".close",
                    function() {
                        t(this).parent().remove()
                    }).appendTo(t(document.body))),
                yt && t(".shop-name").remove(),
                    P(),
                    q()
            }
            function o() {
                var e = location.search.slice(1);
                return e ? e.split("&").reduce(function(e, t) {
                        var n = t.split("=");
                        return e[n[0]] = n[1],
                            e
                    },
                    {}) : {}
            }
            function a() {
                if (window.TM.ENV.isInToutiao) {
                    mt = pt.NOT_VERIFIED;
                    var e = X.find('[name="post_tel"]').val();
                    e && /^1\d{10}$/.test(e) && t.ajax({
                        url: "/order/checkLegalOrder",
                        method: "post",
                        data: {
                            post_tel: e
                        }
                    }).always(function(e) {
                        var t = !1;
                        0 === e.st ? mt = pt.VERIFIED_OK: 10005 === e.st ? mt = pt.FORBIDDEN: 10009 === e.st || 10010 === e.st ? (t = !0, mt = pt.NEED_CODE) : mt = pt.UNCLEAR,
                            i(t)
                    })
                }
            }
            function i(e) {
                X.find(".field-group-code").toggle(e)
            }
            function r() {
                t("#slick-container").slick({
                    infinite: !1,
                    slidesToShow: 1,
                    dots: !0,
                    centerMode: !0,
                    centerPadding: "0px"
                })
            }
            function c(e) {
                function t() {
                    n-->0 ? (o.text("请等待" + n + "秒"), setTimeout(t, 1e3)) : (o.text("获取手机验证码").removeClass("disabled"), _t = !1)
                }
                _t = !0,
                    d(e);
                var n = 60,
                    o = X.find(".getCodeBtn").addClass("disabled");
                t()
            }
            function d(e) {
                t.ajax({
                    url: "/order/sendcode",
                    type: "post",
                    dataType: "json",
                    data: {
                        tel: e
                    }
                }).always(function(e) {
                    e && 0 === e.st || L(e.msg || "获取验证码失败")
                })
            }
            function s() {
                var e = {};
                if (e.combo_id = X.find(".radio-container-combo").find(".active").data("id"), !T(e.combo_id, "请选择产品") && (e.combo_num = X.find('[name="combo_num"]').val(), !T(e.combo_num, "请填写购买数量") && !(g(e.combo_num, "请填写正确的购买数量") || y(e.combo_num, "超过最大购买数量，请减少购买数量") || (e.post_receiver = X.find('[name="post_receiver"]').val(), T(e.post_receiver, "请填写姓名") || N(e.post_receiver, "姓名太长了", 20) || (e.post_tel = X.find('[name="post_tel"]').val(), T(e.post_tel, "请填写手机号码") || O(e.post_tel, "请填写正确的手机号码") || (!window.TM.ENV.isInToutiao || mt === pt.NEED_CODE) && (e.code = X.find('[name="code"]').val(), (e.buyer_words = X.find('[name="buyer_words"]').val(), N(e.buyer_words, "用户留言太长了", 500)))))))) {
                    var n = [];
                    X.find(".radio-container-spec").each(function() {
                        var e = t(this);
                        n.push({
                            name: e.data("spec"),
                            value: e.find(".active").text()
                        })
                    });
                    for (var o = 0; o < n.length; o++) if (T(n[o].value, "请选择产品" + n[o].name)) return;
                    var a = {};
                    if (a.province = {
                            id: Z.val(),
                            name: Z.find("option:selected").text()
                        },
                            !(T(a.province.id, "请选择省份") || (a.city = {
                                id: et.val(),
                                name: et.find("option:selected").text()
                            },
                            T(a.city.id, "请选择城市") || (a.town = {
                                id: tt.val(),
                                name: tt.find("option:selected").text()
                            },
                           (a.detail = X.find('[name="detail"]').val(), T(a.detail, "请填写详细地址") || N(a.detail, "详细地址太长了", 60)))))) return e.spec_desc = n,
                        e.post_addr = a,
                        e.product_id = z,
                        l(e),
                        e
                }
            }
            function l(e) {
                var t = location.href,
                    n = TM.common.getUrlParam(t, "source_type");
                if (n && "0" != n) e.source_type = n,
                    e.source_id = TM.common.getUrlParam(t, "source_id") || 0;
                else if (TM.ENV.isInToutiao) e.source_type = 1,
                    e.source_id = TM.ENV.cid;
                else {
                    var o, a;
                    try {
                        ot = JSON.parse(decodeURIComponent(TM.common.getUrlParam(t, "_toutiao_params"))),
                            o = ot.cid,
                            a = ot.rit
                    } catch(i) {
                        console.log(i)
                    }
                    o && a && a > 9e8 && 1e9 > a ? (e.source_type = 8, e.source_id = o) : e.source_type = 6
                }
            }
            function u() {
                var e = t.Deferred();
                return ft.off().on("click", ".confirmOrder",
                    function() {
                        e.resolve(),
                            ft.hide()
                    }).on("click", ".cancelOrder",
                    function() {
                        e.reject(),
                            ft.hide()
                    }).show(),
                    e.promise()
            }
            function _(e) {
                st || (Ot && (e.hasRedPocket = !0), f(), t.ajax({
                    url: "/wap/spread/order-save",
                    type: "post",
                    dataType: "json",
                    data: e
                }).always(function(t) {
                    //S(e, t),
                    st = !t.st,
                        p(),
                        t.st==1 ? L(t.msg || "下单成功") :  L(t.msg || "下单失败")
                }))
            }
            function f() {
                X.find(".btn-submit").addClass("disabled"),
                    st = !0
            }
            function p() {
                setTimeout(function() {
                        X.find(".btn-submit").removeClass("disabled"),
                            st = !1
                    },
                    1e3)
            }
            function m() {
                var e = X.find('[name="total_amount"]'),
                    n = X.find('[name="combo_num"]').val(),
                    o = X.find(".radio-container-combo").find(".active").data("price");
                if (n = parseInt(n), o = parseInt(o), isNaN(n) || isNaN(o));
                else if (o = o * n , Ot) {
                    var a = parseInt(.8 * o);
                    e.val(a),
                        t(".header-notice .money-amount").html(o - a),
                        e.siblings(".money-reduce-note").length ? e.siblings(".money-reduce-note").html("原价" + o + "元，红包已抵扣" + (o - a) + "元现金") : e.parent().append("<span class='money-reduce-note'>原价" + o + "元，红包已抵扣" + (o - a) + "元现金</span>")
                } else e.val(o)
            }
            function v() {
                var e = this.value;
                t.ajax({
                    url: "/wap/global/location",
                    type: "get",
                    dataType: "json",
                    data: {
                        pid: e
                    }
                }).always(function(e) {
                    if (e.data && e.data.length) {
                        et.html(e.data.map(function(e) {
                            return '<option value="' + e.id + '">' + e.name + "</option>"
                        }).join(""));
                        var t = et.data("id");
                        t ? (et.removeData("id"), et.val(t).change()) : et.change()
                    }
                })
            }
            function h() {
                var e = this.value;
                t.ajax({
                    url: "/wap/global/location",
                    type: "get",
                    dataType: "json",
                    data: {
                        pid: e
                    }
                }).always(function(e) {
                    if (e.data && e.data.length) {
                        tt.html(e.data.map(function(e) {
                            return '<option value="' + e.id + '">' + e.name + "</option>"
                        }).join(""));
                        var t = tt.data("id");
                        t && (tt.removeData("id"), tt.val(t))
                    }
                })
            }
            function T(e, t) {
                return e ? void 0 : (L(t), !0)
            }
            function N(e, t, n) {
                return n = n || 999,
                    e && e.length > n ? (L(t), !0) : void 0
            }
            function g(e, t) {
                var n = parseInt(e);
                return isNaN(n) || 0 >= n || n != e ? (L(t), !0) : void 0
            }
            function y(e, t) {
                var n = parseInt(e);
                return isNaN(n) || n > 99999 ? (L(t), !0) : void 0
            }
            function O(e, t) {
                return e && /^1\d{10}$/.test(e) ? void 0 : (L(t), !0)
            }
            function E() {
                ut = X.offset().top;
                var e = rt.height(),
                    n = !0,
                    o = t(".fixed_bar");
                return function() {
                    var a = rt.scrollTop();
                    n ? a + e > ut && (n = !1, o.hide(), t(".header-notice").hide(), I(), V(), vt || Y(!0)) : ut > a + e && (n = !0, o.show(), t(".header-notice").show())
                }
            }
            function I() {
                //ct || (ct = !0, t.ajax({
                //    url: "/product/orderinfo",
                //    type: "get",
                //    dataType: "json",
                //    data: {
                //        id: z
                //    }
                //}).always(function(e) {
                //    0 === e.st && e.data && (lt = e.data.is_dup, e.data.order && e.data.order.length && b(e.data.order), e.data.address && w(e.data.address))
                //}))
            }
            function b(e) {
                if (1 == t("#buy_record_switch").val()) {
                    for (var n, o, a, i, r = "",
                             c = 0,
                             d = 0; d < e.length; d++) i = e[d],
                    i.post_receiver && i.post_tel && i.create_time && i.combo_name && (a = C(i.create_time), a && (n = i.post_receiver[0] + new Array(i.post_receiver.length).join("*"), o = ("" + i.post_tel).replace(/^(\d{3})\d{4}(\d*)$/, "$1****$2"), c++, r += "<li>" + n + "(" + o + ")在" + a + "前订购了 " + i.combo_name + " " + i.spec_desc + "</li>"));
                    r && (t("#buy-history-list").find("ul").html(r).end().show(), c > 4 && D())
                }
            }
            function w(e) {
                e && e.province && e.city && e.area && (X.find('[name="post_tel"]').val(e.mobile), X.find('[name="post_receiver"]').val(e.receiver), X.find('[name="detail"]').val(e.details), tt.data("id", e.area), et.data("id", e.city), Z.val(e.province).change(), a(e.mobile))
            }
            function C(e) {
                e = "" + e;
                var t = new Date - new Date(e.replace(/-/g, "/"));
                if (! (isNaN(t) || 0 > t || t >= 864e5)) return 36e5 > t ? ~~ (t / 6e4) + "分钟": ~~ (t / 36e5) + "小时"
            }
            function D() {
                function e() {
                    var t = (new Date - i) * a / 1e3;
                    t = Math.floor(t),
                        t %= o,
                        n.css("transform", "translateY(" + -t + "px)"),
                        setTimeout(e, 16)
                }
                var n = t("#buy-history-list").find("ul"),
                    o = n.height(),
                    a = 10,
                    i = new Date;
                n.children().slice(0, 4).clone().appendTo(n),
                    e()
            }
            function R() {
                function e() {
                    var t = d - new Date;
                    if (!isNaN(t) && t > 0) {
                        var n = ~~ (t / 864e5);
                        t %= 864e5;
                        var c = ~~ (t / 36e5);
                        t %= 36e5;
                        var s = ~~ (t / 6e4);
                        t %= 6e4;
                        var l = ~~ (t / 1e3);
                        o.text(n),
                            a.text(c),
                            i.text(s),
                            r.text(l),
                            setTimeout(e, 1e3)
                    }
                }
                var n = t(".time-container"),
                    o = t(".dd", n),
                    a = t(".hh", n),
                    i = t(".mm", n),
                    r = t(".ss", n),
                    c = n.data("remain"),
                    d = new Date(1e3 * c);
                e()
            }
            function x(e) {
                var t = null;
                return function() {
                    t && clearTimeout(t),
                        t = setTimeout(e, 300)
                }
            }
            function L(e) {
                return it.text(e).fadeIn("fast").delay(2e3).fadeOut("fast")
            }
            function k() {
                t("#success-page").show().on("click", ".go_to_channel_link", U).on("click", ".go_to_channel_link_all", U),
                    t("#main").remove(),
                    t(".fixed_bar").remove(),
                    t(".header-notice").remove()
            }
            function U() {
                t.get("/subscribe/like"),
                    location.href = window.TM.ENV.isInToutiao ? "sslocal://profile?uid=6768100064": "http://www.toutiao.com/c/user/6768100064/"
            }
            function S(e, t) {
                j(1, {
                    form: e,
                    result: t,
                    env: window.TM.ENV,
                    agent: navigator.userAgent,
                    location: location.href
                })
            }
            function j(e, n) {
                t.post({
                    url: "/log/saveLogEvent",
                    data: {
                        type: e,
                        msg: n
                    }
                })
            }
            function B(e) {
                return e = e || new Date,
                e.toISOString().slice(0, 10) + " " + e.toTimeString().slice(0, 8)
            }
            function M() {
                if (ot) {
                    var e = new Date,
                        n = e.getTime() - nt;
                    t.ajax({
                        url: "https://i.snssdk.com/api/ad/union/convert_event/",
                        method: "POST",
                        headers: {
                            "content-type": "application/json"
                        },
                        data: JSON.stringify({
                            header: {
                                ua: navigator.userAgent,
                                device_type: window.TM.ENV.device_type
                            },
                            event: {
                                tag: "embeded_ad",
                                label: "convert",
                                convert_id: "0",
                                datetime: B(e),
                                event_type: "shopping",
                                value: ot.cid,
                                category: "app_union",
                                log_extra: ot.log_extra,
                                is_ad_event: "1",
                                show_time: n,
                                user_id: ot.user_id,
                                nt: 0
                            },
                            api_time: e.getTime(),
                            ut: 14,
                            uid: ot.uid,
                            sign: ot.sign
                        })
                    })
                }
            }
            function K() {
                t(".radio-container").on("click", "span",
                    function() {
                        t(this).addClass("active").siblings().removeClass("active"),
                            m()
                    })
            }
            function V() {
                dt || (dt = !0, TM.stat.sendUmeng({
                    tag: "shopping",
                    label: "to_order_module",
                    value: "0"
                }))
            }
            function P() {
                W(Tt.DISPLAY, {},
                    !1)
            }
            function H() {
                W(Tt.ORDER_SUCCESSED, {},
                    !0)
            }
            function F() {
                gt & Nt.ORDER_ONLINE_BUTTON_CLICK || (W(Tt.CLICK_ORDER_ONLINE_BUTTON, {},
                    !0), gt |= Nt.ORDER_ONLINE_BUTTON_CLICK)
            }
            function A() {
                gt & Nt.ORDER_RIGHT_NOW_BUTTON_CLICK || (W(Tt.CLICK_ORDER_RIGHT_NOW_BUTTON, {},
                    !0), gt |= Nt.ORDER_RIGHT_NOW_BUTTON_CLICK)
            }
            function G() {
                gt & Nt.CONSULT_ON_PHONE_BUTTON_CLICK || (W(Tt.CLICK_CONSULT_ON_PHONE_BUTTON, {},
                    !0), gt |= Nt.CONSULT_ON_PHONE_BUTTON_CLICK)
            }
            function W(e, t, n) {
                if (!n || $()) {
                    var o = {
                        tag: "activity_commodity_list",
                        label: e,
                        extra: t || {}
                    };
                    o.extra.source_id = at.source_id,
                        o.extra.source_type = at.source_type,
                        o.extra.display_mode = at.link_type,
                        o.extra.product_id = at.id,
                        o.extra.goods_type = at.goods_type,
                        TM.stat.sendUmeng(o)
                }
            }
            function $() {
                return yt
            }
            function J() {
                window.ToutiaoJSBridge.call("close")
            }
            function Y(e) {
                var t, n = !e;
                if (vt = !0, e) {
                    var o = TM.ENV.user_id || TM.ENV.device_id;
                    t = -1 !== ht.indexOf("" + o) ? 1 : localStorage.getItem("__randomTest__") || parseInt(10 * Math.random()),
                        n = 1 == t || 2 == t,
                        localStorage.setItem("__randomTest__", t)
                }
                if (n && e) {
                    var a = location.href;
                    history.replaceState({
                            page: "productList",
                            href: "/html/20170614/index.html?open_type=" + t
                        },
                        null, "/html/20170614/index.html?open_type=" + t),
                        history.pushState({
                                page: "productDetail",
                                href: a
                            },
                            null, a),
                        window.onpopstate = function(e) {
                            var t = e.state;
                            t && "productList" === t.page && (Et && !$() ? J() : (document.body.scrollTop = 0, location.reload()))
                        }
                }
            }
            function q() {
                var e = t(".sell-num");
                e.length && t.ajax({
                    url: "/product/getSellNum",
                    type: "GET",
                    dataType: "json",
                    data: {
                        id: z
                    }
                }).done(function(t) {
                    0 === t.st && e.text(t.data + "人已购买")
                })
            }
            var z = t("#product_id").val(),
                Q = t("#img_style_switch").val(),
                X = t("#form-container").find("form"),
                Z = t("[name=province]", X),
                et = t("[name=city]", X),
                tt = t("[name=town]", X),
                nt = (new Date).getTime(),
                ot = null,
                at = o(),
                it = t(".toast_tip"),
                rt = t(window),
                ct = !1,
                dt = !1,
                st = !1,
                lt = 0,
                ut = 0,
                _t = !1,
                ft = t("#confirm-order-container"),
                pt = {
                    NONE: "none",
                    NOT_VERIFIED: "not-verified",
                    VERIFIED_OK: "verified-ok",
                    NEED_CODE: "need-code",
                    FORBIDDEN: "forbidden",
                    UNCLEAR: "unclear"
                },
                mt = window.TM.ENV.isInToutiao ? pt.NOT_VERIFIED: pt.NONE,
                vt = !1,
                ht = ["6098236588", "59893576433", "5512123529", "3334694675", "51442571655", "51887250639", "6117889864", "55698236298", "4043299610", "50035471643", "6723654026", "1912356247", "6768100064", "5883140218", "5004813826", "9566350704"],
                Tt = {
                    DISPLAY: "product_first_sight_5_1",
                    ORDER_SUCCESSED: "product_order_successed_5_1",
                    CLICK_ORDER_ONLINE_BUTTON: "product_order_online_5_1",
                    CLICK_ORDER_RIGHT_NOW_BUTTON: "product_order_right_now_5_1",
                    CLICK_CONSULT_ON_PHONE_BUTTON: "product_consult_on_phone_5_1"
                },
                Nt = {
                    ORDER_RIGHT_NOW_BUTTON_CLICK: 1,
                    ORDER_ONLINE_BUTTON_CLICK: 2,
                    CONSULT_ON_PHONE_BUTTON_CLICK: 4
                },
                gt = 0,
                yt = 5 == at.source_type && 1 == at.source_id,
                Ot = yt && 2 == at.link_type,
                Et = !1;
            e(),
                X.on("click", ".btn-submit",
                    function(e) {
                        if (e.preventDefault(), X.find('[name="post_tel"]').val() && mt === pt.NOT_VERIFIED) return void L("网络延时，请您稍后下单");
                        if (mt === pt.FORBIDDEN) return void L("您今天下单太多啦，休息一会吧");
                        var t = s();
                        t && (lt ? u().done(function() {
                            _(t)
                        }) : _(t))
                    }).on("click", ".combo-num-min",
                    function() {
                        var e = X.find('[name="combo_num"]'),
                            t = parseInt(e.val());
                        isNaN(t) || 2 > t ? t = 1 : t--,
                            e.val(t).change()
                    }).on("click", ".combo-num-max",
                    function() {
                        var e = X.find('[name="combo_num"]'),
                            t = parseInt(e.val());
                        isNaN(t) ? t = 1 : t++,
                            e.val(t).change()
                    }).on("click", ".getCodeBtn",
                    function() {
                        if (!_t) {
                            var e = X.find('[name="post_tel"]').val();
                            T(e, "请首先填写手机号码，再发送验证码") || O(e, "请填写正确的手机号码，再发送验证码") || c(e)
                        }
                    }).on("change", "[name=combo_num]", m).on("change", "[name=province]", v).on("change", "[name=city]", h).on("blur", "[name=post_tel]", a)
        })
    });